package org.smr.ministore.micro.client;

import java.util.Collections;
import java.util.List;

import org.blade.utils.Pager;
import org.smr.ministore.entities.Authority;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import feign.hystrix.FallbackFactory;
import org.springframework.web.bind.annotation.PathVariable;

@Component
public class HystrixAuthorityClientFactory implements FallbackFactory<FeignAuthorityMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixAuthorityClientFactory.class);

    @Override
    public FeignAuthorityMicroServiceClient create(Throwable cause) {
        HystrixAuthorityClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new AuthorityFeignClientWithFactory() {

            @Override
            public Authority queryById( Long id ) {
                Authority entity = new Authority();
                entity.setId(-1L);
                return entity;
            }

            @Override
            public int batchSave( List< Authority> entities){
                return 0;
            }



            public int save(Authority entity){
                return 0;
            }

            public int updateById(Authority id){
                return 0;
            }

            public int deleteById(Long id){
                 return 0;
            }

            public Pager<Authority> paginate( Authority entity, Long pageSize, Long pageNum){
                Pager<Authority> pager = new Pager<Authority>();
                return pager;
            }

            public List<Authority> getByParentAndType(Long parentId, Integer type){
                return Collections.emptyList();
            }

        };//Return end
    }
}